package com.jfs.security.annotations;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * @Description 自定义权限注解
 * @E-mail cwm3412638@163.com
 * @Author cwm
 * @Date 2022/8/9
 */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface HasAuthority {
    /**
     * 默认为1只有可读权限
     *
     * @return
     */
    HasAuthorityEnum value() default HasAuthorityEnum.Read;

    @AllArgsConstructor
    @Getter
     enum HasAuthorityEnum{
        /**
         * 可读权限
         */
        Read(1),
        /**
         * 可写权限
         */
        Write(2),
        /**
         * 可读可写权限
         */
        ReadAndWrite(3);
        private final Integer value;
    }
}
